
/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __HOODS_ABILITY_SLICE_H__
#define __HOODS_ABILITY_SLICE_H__

#include <ability_loader.h>
#include <common/task.h>
#include "components/ui_image_view.h"
#include "components/ui_view_group.h"
#include "components/ui_label.h"
#include "components/root_view.h"

#include "event_listener.h"
#include "popup_dialog.h"

namespace OHOS {
class HoodsAbilitySlice : public AbilitySlice, Task {
public:
    HoodsAbilitySlice();
    ~HoodsAbilitySlice() override;

    void Callback() override;
    int DialogDisplay(const char *msg, int type, int timeout);

protected:
    void OnStart(const Want &want) override;
    void OnInactive() override;
    void OnActive(const Want &want) override;
    void OnBackground() override;
    void OnStop() override;

private:
    static constexpr int TASK_TIME_OUT = 300;
    static constexpr int ITEM_COUNT = 4;
    static constexpr int LABEL_COUNT = 5;

    static constexpr int VIDEO_ITEM = 0;
    static constexpr int IMAGE_ITEM = 1;
    static constexpr int CAME0_ITEM = 2;
    static constexpr int CAME1_ITEM = 3;

    static constexpr int DATE_LABEL_ID = 0;
    static constexpr int TIME_LABEL_ID = 1;
    static constexpr int WEEK_LABEL_ID = 2;
    static constexpr int TEMP_LABEL_ID = 3;
    static constexpr int WEATH_LABEL_ID = 4;

    RootView *rootView_ { nullptr };

    UIImageView *background_ { nullptr };
    UIImageView *backButton_ { nullptr };
    UIImageView *backClickImage_ { nullptr };

    UIViewGroup *weatherDateGroup_ { nullptr };
    UIImageView *weatherBackground_ { nullptr };
    UILabel *dateLabel_ { nullptr };
    UILabel *timeLabel_ { nullptr };
    UILabel *weekLabel_ { nullptr };
    UILabel *tempLabel_ { nullptr };
    UILabel *weatherLabel_ { nullptr };

    UIViewGroup *itemGroup_ { nullptr };
    UILabel *listLabel_[ITEM_COUNT];

    HoodsButtonClickListener *backClickListener_ { nullptr };
    PopupDialog *dialog_ { nullptr };

    bool g_isActivity_ = false;
    uint32_t g_timeCount_ = 0;
    int32_t g_minute_ = -1;

    int g_videoNumber_ = 0;
    int g_pictrueNumber_ = 0;

    void SetTimeWeatherView();
    void SetListItem();
    void UpdateVideoImage(int type);
    void UpdateTime(bool draw);

    bool FileIsUpdate();\
};
}

#endif  /* __HOODS_ABILITY_SLICE_H__ */
